import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '概况分类',
    align:"center",
    dataIndex: 'type_dictText'
   },
   {
    title: '标题',
    align:"center",
    dataIndex: 'titile'
   },
   {
    title: '预览图',
    align:"center",
    dataIndex: 'coverImage',
    customRender:render.renderImage,
   },
   {
    title: '摘要',
    align:"center",
    dataIndex: 'summary'
   },
   {
    title: '发布状态',
    align:"center",
    dataIndex: 'publishStatus_dictText'
   },
   {
    title: '发布人',
    align:"center",
    dataIndex: 'publisher'
   },
   {
    title: '发布时间',
    align:"center",
    dataIndex: 'publishTime'
   },
  
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "概况分类",
      field: 'type',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"web_school_introduction_type"
      },
      //colProps: {span: 6},
 	},
	{
      label: "标题",
      field: 'titile',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "内容",
      field: 'content',
      component: 'Input',
      //colProps: {span: 6},
 	},
     {
      label: "发布人",
      field: "publisher",
      component: 'Input', //TODO 范围查询
      //colProps: {span: 6},
	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '概况分类',
    field: 'type',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"web_school_introduction_type"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请选择概况分类!'},
          ];
     },
  },
  {
    label: '标题',
    field: 'titile',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入标题!'},
          ];
     },
  },
  {
    label: '摘要',
    field: 'summary',
    component: 'InputTextArea',
  },
  {
    label: '内容',
    field: 'content',
    component: 'JEditor',
  },
  {
    label: '发布状态',
    field: 'publishStatus',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"web_publish_status"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请选择发布状态!'},
          ];
     },
  },
  {
    label: '发布人',
    field: 'publisher',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入发布人!'},
          ];
     },
  },
  {
    label: '发布时间',
    field: 'publishTime',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入发布时间!'},
          ];
     },
  },
  
  {
    label: '预览图',
   field: 'coverImage',
   component: 'JImageUpload',
   componentProps:{
      fileMax: 1
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  type: {title: '概况分类',order: 0,view: 'list', type: 'string',dictCode: 'web_school_introduction_type',},
  titile: {title: '标题',order: 1,view: 'text', type: 'string',},
  summary: {title: '摘要',order: 2,view: 'textarea', type: 'string',},
  publishStatus: {title: '发布状态',order: 4,view: 'list', type: 'string',dictCode: 'web_publish_status',},
  publisher: {title: '发布人',order: 5,view: 'text', type: 'string',},
  publishTime: {title: '发布时间',order: 6,view: 'datetime', type: 'string',},
  coverImage: {title: '预览图',order: 9,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
